import java.util.*;

/**
 * This class stores information about an order
 */
public class Order {

    private Date requestedDeliveryDate;
    private int orderId;
    private int userId;
    private int status;
    private LineItem[] items;

    // status constants
    public static final int ORDER_RECEIVED = 1;
    public static final int ESTIMATE_RECEIVED = 2;
    public static final int ORDER_CANCELLED = -1;
    public static final int ORDER_CONFIRMED = 3;
    public static final int ORDER_SHIPPED = 4;

    /**
     * Default constructor
     */
    public Order() {
        this(-1, -1, new LineItem[17], new Date());
    }

    /**
     * More detailed constructor: sets all order information on creation
     *
     * @param orderId
     * @param userId
     * @param items
     * @param requestedDeliveryDate
     * @param requestedDeliveryTime
     */
    public Order(int orderId, int userId, LineItem[] items, Date requestedDeliveryDate) {
        this.orderId = orderId;
        this.userId = userId;
        this.items = items;
        this.requestedDeliveryDate = requestedDeliveryDate;
        this.status = ORDER_RECEIVED;
    }

    /**
     * @return Returns the id of the order
     */
    public int getOrderId () {
        return orderId;
    }

    /**
     * Sets the id of the order
     *
     * @param val The id of the order
     */
    public void setOrderId (int val) {
        this.orderId = val;
    }

    /**
     * @return Returns the id of the user who placed the order
     */
    public int getUserId () {
        return userId;
    }

    /**
     * Sets the id of the user who placed the order
     *
     * @param val The id of the user
     */
    public void setUserId (int val) {
        this.userId = val;
    }

    /**
     * @return Returns the items the user has placed
     */
    public LineItem[] getItems () {
        return items;
    }

    /**
     * Sets the items the user has placed
     *
     * @param val The items the user has placed
     */
    public void setItems (LineItem[] val) {
        this.items = val;
    }


    /**
     * @return Returns the date object representing the day the user wishes to
     * get their order delivered
     */
    public Date getRequestedDeliveryDate () {
        return requestedDeliveryDate;
    }

    public void setRequestedDeliveryDate(Date date){
        this.requestedDeliveryDate = date;
        
    }
    /**
     * @return Returns the status of the order
     */
    public int getStatus () {
        return status;
    }

    /**
     * Sets the status of the order
     *
     * @param val The status of the order
     */
    public void setStatus (int val) {
        this.status = val;
    }

    // for debugging
    @Override
    public String toString() {
        String rString = orderId+"\n"+userId+"\n"+requestedDeliveryDate+"\n"+status+"\n";
        for (LineItem item : items) {
            rString = rString + item.getItem() + " - " + item.getQuantity() + "\n";
        }
        return rString;
    }

}
